/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.jr2tecnologia.model.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author ronildo
 */
@Entity
@Table(name = "key_response")
@NamedQueries({
    @NamedQuery(name = "KeyResponse.findAll", query = "SELECT k FROM KeyResponse k"),
    @NamedQuery(name = "KeyResponse.findByPkKeyResponse", query = "SELECT k FROM KeyResponse k WHERE k.pkKeyResponse = :pkKeyResponse"),
    @NamedQuery(name = "KeyResponse.findByName", query = "SELECT k FROM KeyResponse k WHERE k.name = :name"),
    @NamedQuery(name = "KeyResponse.findByDescription", query = "SELECT k FROM KeyResponse k WHERE k.description = :description"),
    @NamedQuery(name = "KeyResponse.findByTip", query = "SELECT k FROM KeyResponse k WHERE k.tip = :tip"),
    @NamedQuery(name = "KeyResponse.findByDefaultKey", query = "SELECT k FROM KeyResponse k WHERE k.defaultKey = :defaultKey")})
public class KeyResponse implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "pk_key_response")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq_key_response")
    @SequenceGenerator(name="seq_key_response", sequenceName="seq_key_response", allocationSize=1)
    private Long pkKeyResponse;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Column(name = "description")
    private String description;
    @Column(name = "tip")
    private String tip;
    @Basic(optional = false)
    @Column(name = "default_key")
    private boolean defaultKey;
    @OneToMany(mappedBy = "keyResponse")
    private List<SmsReceived> smsReceivedList;
    @JoinColumn(name = "fk_login", referencedColumnName = "pk_login")
    @ManyToOne(optional = false)
    private Login login;

    public KeyResponse() {
    }

    public KeyResponse(Long pkKeyResponse) {
        this.pkKeyResponse = pkKeyResponse;
    }

    public KeyResponse(Long pkKeyResponse, String name, boolean defaultKey) {
        this.pkKeyResponse = pkKeyResponse;
        this.name = name;
        this.defaultKey = defaultKey;
    }

    public Long getPkKeyResponse() {
        return pkKeyResponse;
    }

    public void setPkKeyResponse(Long pkKeyResponse) {
        this.pkKeyResponse = pkKeyResponse;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getTip() {
        return tip;
    }

    public void setTip(String tip) {
        this.tip = tip;
    }

    public boolean getDefaultKey() {
        return defaultKey;
    }

    public void setDefaultKey(boolean defaultKey) {
        this.defaultKey = defaultKey;
    }

    public List<SmsReceived> getSmsReceivedList() {
        return smsReceivedList;
    }

    public void setSmsReceivedList(List<SmsReceived> smsReceivedList) {
        this.smsReceivedList = smsReceivedList;
    }

    public Login getLogin() {
        return login;
    }

    public void setLogin(Login login) {
        this.login = login;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pkKeyResponse != null ? pkKeyResponse.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof KeyResponse)) {
            return false;
        }
        KeyResponse other = (KeyResponse) object;
        if ((this.pkKeyResponse == null && other.pkKeyResponse != null) || (this.pkKeyResponse != null && !this.pkKeyResponse.equals(other.pkKeyResponse))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.jr2tecnologia.model.entity.KeyResponse[pkKeyResponse=" + pkKeyResponse + "]";
    }

}
